package material.iteratorAndComponent.improveWaitress;


import material.iteratorAndComponent.MenuItem;
import material.iteratorAndComponent.caffee.CafeMenu;
import material.iteratorAndComponent.interal.DinerMenu;
import material.iteratorAndComponent.interal.Menu;
import material.iteratorAndComponent.interal.PancakeHouseMenu;

import java.util.ArrayList;
import java.util.Iterator;

public class Waitress {
    ArrayList menus;

    public Waitress(ArrayList menus) {
        this.menus = menus;
    }

    public void printMenu() {
        Iterator menuIterator = menus.iterator();
        while (menuIterator.hasNext()) {
            Menu menu = (Menu) menuIterator.next();
            printMenu(menu.createIterator());
        }
    }

    private void printMenu(Iterator iterator) {
        while (iterator.hasNext()) {
            MenuItem menuItem = (MenuItem) iterator.next();
            System.out.println(menuItem.getName() + ", ");
            System.out.println(menuItem.getPrice() + ", ");
            System.out.println(menuItem.getDescription() + ", ");
        }
    }
}
